<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网络协议选择指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-gradient::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            bottom: -50%;
            left: -50%;
            background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
            animation: drift 20s infinite linear;
        }
        
        @keyframes drift {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        }
        
        .section-title {
            position: relative;
            display: inline-block;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .protocol-card {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        
        .protocol-card::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: rgba(255, 255, 255, 0.1);
            transform: rotate(45deg);
            transition: all 0.5s ease;
        }
        
        .protocol-card:hover::before {
            top: -100%;
            right: -100%;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            position: relative;
            overflow: hidden;
        }
        
        .code-block::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 40px;
            background: #2d2d2d;
            border-bottom: 1px solid #3e3e3e;
        }
        
        .code-dots {
            position: absolute;
            top: 12px;
            left: 20px;
            display: flex;
            gap: 8px;
        }
        
        .code-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
        }
        
        .highlight-text {
            background: linear-gradient(120deg, #f093fb 0%, #f5576c 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            font-weight: 700;
        }
        
        .floating-icon {
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-20px); }
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-8 relative">
        <div class="max-w-6xl mx-auto relative z-10">
            <div class="text-center">
                <i class="fas fa-network-wired text-6xl mb-6 floating-icon"></i>
                <h1 class="text-5xl md:text-6xl font-bold mb-6">网络协议选择指南</h1>
                <p class="text-xl md:text-2xl font-light max-w-3xl mx-auto leading-relaxed">
                    深入理解客户端如何智能选择网络协议，掌握现代网络编程的核心要素
                </p>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-8 py-16">
        <!-- Introduction Card -->
        <div class="content-card rounded-2xl p-10 mb-12">
            <p class="text-lg leading-relaxed text-gray-700">
                在网络编程的世界里，选择正确的通信协议就像为旅程选择合适的交通工具。每种协议都有其独特的优势和适用场景，理解这些差异是构建高效网络应用的关键。让我们深入探索客户端如何做出这个关键决策。
            </p>
        </div>

        <!-- Protocol Selection Basis -->
        <div class="mb-16">
            <h2 class="section-title text-4xl font-bold mb-12 text-gray-800">
                <i class="fas fa-compass mr-3 text-purple-600"></i>协议选择的智慧
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="content-card rounded-xl p-8">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-layer-group text-3xl text-purple-600 mr-4"></i>
                        <h3 class="text-2xl font-bold text-gray-800">应用层协议功能</h3>
                    </div>
                    <p class="text-gray-600 leading-relaxed">
                        每种应用层协议都是为特定任务而生。HTTP/HTTPS主导着Web世界，FTP专注于文件传输，SMTP负责邮件投递。选择协议就像选择工具，要与任务完美匹配。
                    </p>
                </div>
                
                <div class="content-card rounded-xl p-8">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-exchange-alt text-3xl text-pink-600 mr-4"></i>
                        <h3 class="text-2xl font-bold text-gray-800">传输层协议特点</h3>
                    </div>
                    <p class="text-gray-600 leading-relaxed">
                        TCP提供可靠的数据传输，确保每个字节都准确到达；UDP追求速度与效率，适合实时应用。选择取决于你更看重可靠性还是实时性。
                    </p>
                </div>
                
                <div class="content-card rounded-xl p-8">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-shield-alt text-3xl text-indigo-600 mr-4"></i>
                        <h3 class="text-2xl font-bold text-gray-800">安全性要求</h3>
                    </div>
                    <p class="text-gray-600 leading-relaxed">
                        在数据安全至关重要的今天，HTTPS通过SSL/TLS加密保护你的数据。当涉及敏感信息传输时，安全协议不是选择，而是必需。
                    </p>
                </div>
                
                <div class="content-card rounded-xl p-8">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-tachometer-alt text-3xl text-green-600 mr-4"></i>
                        <h3 class="text-2xl font-bold text-gray-800">性能与实时性</h3>
                    </div>
                    <p class="text-gray-600 leading-relaxed">
                        视频流、在线游戏等应用对延迟极其敏感。UDP的低延迟特性使其成为这些场景的理想选择，即使偶尔丢失数据包也在所不惜。
                    </p>
                </div>
            </div>
        </div>

        <!-- Protocol Visualization -->
        <div class="content-card rounded-2xl p-10 mb-16">
            <h3 class="text-3xl font-bold mb-8 text-center text-gray-800">协议关系图谱</h3>
            <div class="mermaid">
                graph TD
                    A[客户端应用] --> B{协议选择}
                    B --> C[应用层协议]
                    B --> D[传输层协议]
                    
                    C --> E[HTTP/HTTPS]
                    C --> F[FTP]
                    C --> G[SMTP]
                    C --> H[其他协议]
                    
                    D --> I[TCP]
                    D --> J[UDP]
                    
                    E --> K[Web浏览]
                    F --> L[文件传输]
                    G --> M[邮件发送]
                    
                    I --> N[可靠传输]
                    J --> O[快速传输]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style B fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                    style E fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                    style I fill:#f5576c,stroke:#fff,stroke-width:2px,color:#fff
                    style J fill:#4facfe,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- How Client Determines Protocol -->
        <div class="mb-16">
            <h2 class="section-title text-4xl font-bold mb-12 text-gray-800">
                <i class="fas fa-route mr-3 text-purple-600"></i>客户端的决策过程
            </h2>

            <!-- URL and Port -->
            <div class="content-card rounded-xl p-10 mb-8">
                <h3 class="text-2xl font-bold mb-6 text-gray-800">
                    <i class="fas fa-link mr-3 text-indigo-600"></i>URL与端口的指引
                </h3>
                <p class="text-lg text-gray-600 mb-6">
                    URL前缀和端口号就像路标，明确指示着协议的方向：
                </p>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="protocol-card rounded-lg p-6">
                        <h4 class="text-xl font-bold mb-4">常见URL前缀</h4>
                        <ul class="space-y-2">
                            <li><i class="fas fa-globe mr-2"></i><code class="bg-white bg-opacity-20 px-2 py-1 rounded">http://</code> - HTTP协议</li>
                            <li><i class="fas fa-lock mr-2"></i><code class="bg-white bg-opacity-20 px-2 py-1 rounded">https://</code> - HTTPS协议</li>
                            <li><i class="fas fa-folder mr-2"></i><code class="bg-white bg-opacity-20 px-2 py-1 rounded">ftp://</code> - FTP协议</li>
                        </ul>
                    </div>
                    
                    <div class="protocol-card rounded-lg p-6" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">
                        <h4 class="text-xl font-bold mb-4">默认端口映射</h4>
                        <ul class="space-y-2">
                            <li><i class="fas fa-door-open mr-2"></i>端口 80 - HTTP</li>
                            <li><i class="fas fa-key mr-2"></i>端口 443 - HTTPS</li>
                            <li><i class="fas fa-upload mr-2"></i>端口 21 - FTP</li>
                            <li><i class="fas fa-envelope mr-2"></i>端口 25 - SMTP</li>
                        </ul>
                    </div>
                </div>
            </div>

            <!-- Code Implementation -->
            <div class="content-card rounded-xl p-10 mb-8">
                <h3 class="text-2xl font-bold mb-6 text-gray-800">
                    <i class="